home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 1.6 KB | 49 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import quicktime.app.image.*;
- import java.util.*;
-
- class JavaText implements Paintable {
- Font font = new Font ("Helvetica", Font.PLAIN, 32);
- int width, height;
- Rectangle[] r = new Rectangle[1];
- Random rand = new Random(); //use this for generating random text colour
-
- public void newSizeNotified (QTImageDrawer drawer, Dimension d) {
- width = d.width;
- height = d.height;
- r[0] = new Rectangle (width, height);
- }
-
- /**
- * Paint on the graphics. The supplied component is the component from which
- * the graphics object was derived or related to and is also the component
- * that is the object that paint was called upon that has called this method.
- * The Graphics object is what you should paint on.
- * This maybe an on or off screen graphics.
- * You should not cache this graphics object as it can be different
- * between different calls.
- * @param comp the component from which the Graphics object was derived or
- * related too.
- * @param g the graphics to paint on.
- */
- public Rectangle[] paint (Graphics g) {
- Color c = new Color (255, Math.abs(rand.nextInt()) % 256, Math.abs(rand.nextInt()) % 256);
- System.out.println ("New TextColor:" + c);
- g.setColor (c);
- g.setFont (font);
- g.drawString ("Java Text", 5, 30);
- g.setColor (Color.red);
- g.drawRect (0, 0, width-1, height-1);
- g.drawRect (1, 1, width-3, height-3);
- g.drawRect (2, 2, width-5, height-5);
- return r;
- }
- }
-